(function (vc) {
    vc.extends({
        data: {
            repairDetailInfo: {
                repairId: '',
                repairType: '',
                repairTypeName: '',
                repairName: '',
                tel: '',
                roomId: '',
                roomName: '',
                repairObjName: '',
                appointmentTime: '',
                submitHours:'',
                timeout:'',
                finishTime:'',
                context: '',
                stateName: '',
                userId: '',
                userName: '',
                _currentTab:'repairDetailPhotos',
                photos: [],
                visitType: '',
                visitContext: '',
                maintenanceType: '',
                repairMaterials: '',
                repairFee: '',
                appraiseScore: 0,
                doorSpeedScore: 0,
                repairmanServiceScore: 0,
                average: 0.0
            }
        },
        _initMethod: function () {
            let repairId = vc.getParam('repairId');
            if (!vc.notNull(repairId)) {
                vc.toast('非法操作');
                vc.jumpToPage('/#/pages/property/repairPoolManage');
                return;
            }
            $that.repairDetailInfo.repairId = repairId;
            $that._listRepairPools()
        },
        _initEvent: function () {
            vc.on('repairDetail','notifyRepairUser',function(){
                $that._loadRepairUser();
            })
        },
        methods: {
            _listRepairPools: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        communityId: vc.getCurrentCommunity().communityId,
                        repairId: $that.repairDetailInfo.repairId
                    }
                };
                //发送get请求
                vc.http.apiGet('/ownerRepair.listOwnerRepairs',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        let _repairs = _json.data;
                        if (_repairs.length < 1) {
                            vc.toast("数据异常");
                            vc.jumpToPage('/#/pages/property/repairPoolManage');
                            return;
                        }
                        vc.copyObject(_repairs[0], $that.repairDetailInfo);
                        //查询房屋信息

                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _goBack: function () {
                vc.goBack()
            },
            openFile: function (_photo) {
                vc.emit('viewImage', 'showImage', {
                    url: _photo.url
                });
            },
            /**
             * 新增打印功能，跳转打印页面
             */
            _printRepairDetail: function () {
                window.open("/print.html#/pages/property/printRepairDetail?repairId=" + $that.repairDetailInfo.repairId + "&repairType=" + $that.repairDetailInfo.repairType)
            },
            changeTab: function (_tab) {
                $that.repairDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    repairId: $that.repairDetailInfo.repairId,
                    repairName: $that.repairDetailInfo.repairName,
                })
            },
        }
    });
})(window.vc);